<%@ page language="java" import="java.util.*,java.sql.*" contentType="text/html;charset=UTF-8"
    pageEncoding="UTF-8" %>
<%@ page import="java.util.Date" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>index.jsp</title>
<style>
body{
        background:url(bg.jpg);
        color:#fff;
        text-align:center;
        font-size:25px;
        font-weight:bold;
        font-family:Serif;
}
div{
        background-color:rgba(238,238,238,0.3);
        width:300px;
        padding:0px 30px 15px 30px;
        margin:8% auto 0 auto;
        border:0.8px  solid #fff;
        border-radius:5px;
}
input{
        background-color:rgba(238,238,238,0.4);
        margin-bottom;15px;
        font-size:13px;
        font-weight:bold;
}
</style>
</head>
<body>
<%!
       public static final String DBDRIVER = "com.mysql.jdbc.Driver";
       public static final String DBURL="jdbc:mysql://localhost:3306/smm";
       public static final String DBUSER = "root";
       public static final String DBPASS = "657287";
%>
<%
       request.setCharacterEncoding("UTF-8");
       String name=request.getParameter("user");
       if(name!=null){
%>     <div>
       <p style="margin-top:25px">当前用户：<%=name %></p>
       <p style="font-size:25px">用户信息列表</p>
<%
       Connection con = null;
       Statement stat = null;
       ResultSet rs = null;
       
       try{
    	   Class.forName(DBDRIVER);
    	   con=DriverManager.getConnection(DBURL,DBUSER,DBPASS);
    	   stat=con.createStatement();
    	   rs=stat.executeQuery("select * from user where username='"+name+"'");
    	   while(rs.next()){
    		   int userid = rs.getInt(1);
    		   String username = rs.getString(2);
    		   String password = rs.getString(3);
    		   String gender = rs.getString(4);
    		   int age = rs.getInt(5);
    		   String email = rs.getString(6);
    		   Date regdatetime = rs.getDate(7);
 %>
           <form action="alter.jsp" method="post">
     I&nbsp;D ：<input type="text" name="userid" value="<%=userid %>" disabled="disabled"><br>
            姓名：<input type="text" name="username" value="<%=username%>"><br>
            密码：<input type="text" name="password" value="<%=password %>"><br>
            性别：<input type="text" name="gender" value="<%=gender%>"><br>
            年龄：<input type="text" name="age" value="<%=age%>"><br>
            邮箱：<input type="text" name="email" value="<%=email%>"><br>
            注册：<input type="text" name="regdatetime" value="<%=regdatetime%>" disabled="disabled"><br>
     <input type="submit" value="修改" style="margin-right:-183px">
           </form>
    <% 
    	   }
       }catch(Exception e){
    	   e.getStackTrace();
       }
%>
</div>
<%  
       }else{
 %>
       <jsp:forward page="login.jsp"></jsp:forward>
       <%
       }
       %>
</body>
</html>